{include file="public/_meta" title="日志管理"/}

<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 日志管理 <span class="c-gray en">&gt;</span> 日志列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <span style="color:red;">* 默认最新日期</span>
    <form action="" method="post" class="form form-horizontal">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-4">请选择日期</label>
            <div class="formControls col-xs-4 col-sm-3">
                <select name="dir_date" class="js-example-basic-single select">
                    {volist name="dir_name" id="vo"}
                    <option {volist name="file" id="val"}{if condition="$vo eq $val.dir_date"} selected="selected" {/if}{/volist} value="{$vo}">{$vo}</option>
                    {/volist}
                </select>
            </div>
            <div class="formControls col-xs-4 col-sm-5">
                <input type="submit" class="btn btn-success radius size-S" value="查看文件列表"/>
            </div>
        </div>
    </form>
    <div class="cl pd-5 bg-1 bk-gray mt-20">
		<span class="l">
			<a href="javascript:;" onclick="dataDel()" class="btn btn-danger radius">
			<i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>
		</span>
        <span class="r">共有数据：<strong>{$count}</strong> 条</span>
    </div>
    <div class="mt-20">
        <table class="table table-border table-bordered table-hover table-bg table-sort">
            <thead>
            <tr class="text-c">
                <th width="25"><input type="checkbox" name="" value=""></th>
                <th width="70">上级目录</th>
                <th width="70">文件名</th>
                <th width="70">文件路径</th>
                <th width="100">操作</th>
            </tr>
            </thead>
            <tbody>
            {volist name="file" id="vo"}
            <tr class="text-c">
                <td><input class="checkbox" type="checkbox" value="{$vo.file_path}" name="param[]"></td>
                <td>{$vo.dir_date}</td>
                <td>{$vo.file_name}</td>
                <td>{$vo.file_path}</td>
                <td class="td-manage">
                    <a title="预览" href="javascript:;" onclick="read_log('预览','{:url(\'Log/read_log\')}?file_path={$vo.dir_date}/{$vo.file_name}','800','400')" class="btn btn-success radius size-S" style="text-decoration:none">
                        <i class="Hui-iconfont">&#xe725;</i>预览
                    </a>&nbsp;
                    <a title="下载" href="{:url('Log/download_log')}?file_path={$vo.dir_date}/{$vo.file_name}" class="btn btn-success radius size-S" style="text-decoration:none">
                        <i class="Hui-iconfont">&#xe640;</i>下载
                    </a>&nbsp;
                    <a title="删除" href="javascript:;" onclick="del_file(this,'{$vo.file_path}')" class="btn btn-danger radius size-S" style="text-decoration:none">
                        <i class="Hui-iconfont">&#xe6e2;</i>删除
                    </a>
                </td>
            </tr>
            {/volist}
            </tbody>
        </table>
        <div id="loadImage"></div>
    </div>
</div>
<!--_footer 作为公共模版分离出去-->
{include file="public/_footer" /}
<!--/_footer 作为公共模版分离出去-->

<script type="text/javascript">
    $(function(){
        $('.table-sort').dataTable({
            "aaSorting": [[ 1, "asc" ]],//默认第几个排序
            "bStateSave": true,//状态保存
            "aoColumnDefs": [
                //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
                {"orderable":false,"aTargets":[0,1,2,4]}// 制定列不参与排序
            ]
        });
    });
    /*下拉查询选择*/
    $(document).ready(function() {
        $('.js-example-basic-single').select2();
    });
</script>
<script>
    /*日志-预览*/
    function read_log(title,url,w,h){
        layer_show(title,url,w,h);
    }

    //下载文件
    function download_file(obj,param){
        $.ajax({
            type:"post",
            url:"{:url('Log/start_download')}",
            data:{param:param},
            dataType:"json",
            success:function(msg){
                if(msg.status == true){
                    layer.msg(msg.message,{icon:6,time:2000});
                    setTimeout(jump,1000);
                    function jump(){
                        parent.layer.close(parent.layer.getFrameIndex(window.name));
                    }
                }else if(msg.status == false){
                    layer.msg(msg.message,{icon:5,time:2000});
                }
            }
        });
    }

    //删除文件
    function del_file(obj,param){
        layer.confirm('确定要删除吗',function(index){
            $.ajax({
                type:"post",
                url:"{:url('Log/del_log')}",
                data:{param:param},
                dataType:"json",
                success:function(msg){
                    if(msg.status == true){
                        $(obj).parents("tr").remove();
                        layer.msg(msg.message,{icon:6,time:2000});
                        setTimeout(jump,1000);
                        function jump(){
                            parent.layer.close(parent.layer.getFrameIndex(window.name));
                        }
                    }else if(msg.status == false){
                        layer.msg(msg.message,{icon:5,time:2000});
                    }
                }
            });
        });
    }

    //批量删除
    function dataDel(){
        var arr = [];
        var param = $("input[name='param[]']:checked");
        param.each(function(){
            arr.push($(this).val());
        });
        $.ajax({
            type : "post",
            url : "{:url('Log/batch_del_log')}",
            data : {param:arr},
            dataType : "json",
            success : function(msg){
                if(msg.status == true){
                    layer.msg(msg.message,{icon:6,time:1000});
                    setTimeout(jump,1000);
                    function jump(){
                        window.location.replace(location.href);
                    }
                }else if(msg.status == false){
                    layer.msg(msg.message,{icon:5,time:2000});
                }
            }
        });
    }
</script>
